package com.reliable.service.controller;

import com.reliable.api.dto.chatmessage.SessionPageTransitionDTO;
import com.reliable.api.dto.chatmessage.SessionPageTransitionPageDTO;
import com.reliable.api.param.chat.SessionPageTransitionParam;
import com.reliable.common.core.domain.AjaxResult;
import com.reliable.service.service.ChatMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 会话页面跳转记录Controller
 */
@RestController
@RequestMapping("/reliable/chat/page-transition")
@Api(value = "会话页面跳转记录", tags = {"会话页面跳转记录管理"})
public class ChatPageTransitionController {

    @Autowired
    private ChatMessageService chatMessageService;

    /**
     * 查询会话页面跳转记录列表
     *
     * @param param 查询参数
     * @return 会话页面跳转记录列表
     */
    @PostMapping("/urlList")
    @ApiOperation("查询会话页面跳转记录列表")
    public AjaxResult list(@RequestBody SessionPageTransitionParam param) {
        SessionPageTransitionPageDTO pageResult = chatMessageService.findUniqueSessionPageTransitionsWithTotal(
                param.getReferrerUrl(),
                param.getPageUrl(),
                param.getPageNum(),
                param.getPageSize()
        );
        return AjaxResult.success(pageResult);
    }
}